﻿/**
 * 
 * @file MaterialEditWidget.h
 * @brief 材料编辑对话框
 * @author BaGuijun (baguijun@163.com)
 * @date 2024-04-07
 * 
 */
#ifndef _MaterialEditWidget_H
#define _MaterialEditWidget_H

#include "GUIPropertyDialogAPI.h"
#include "GUIWidget/GUIDialogBase.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialBehavior.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterial.h"
#include "OperatorsInterface/ParaWidgetInterfaceOperator.h"
#include"MaterialWidgetBase.h"
#include "GUIDialog/GUICalculateDialog/GUICalculateWidgetBase.h"
class QListWidgetItem;

namespace Ui{
    class MaterialEditWidget;
}

namespace Core {
    class FITKWidget;
}

namespace Interface {
    class FITKAbstractMaterial;
    class FITKAbaMaterial;
    class FITKMaterialManager;
    class FITKAbaMaterialBehavior;
}

namespace EventOper {
    class ParaWidgetInterfaceOperator;
}

namespace GUI
{
    class MainWindow;
    class MaterialWidgetBase;

    class GUIPropertyDialogAPI MaterialEditWidget :public MaterialWidgetBase
    {
        Q_OBJECT;
    public:
        /**
         * @brief Construct a new Material Edit Dialog object
         * @param[i]  material       材料对象
         * @param[i]  oper           操作器对象
         * @param[i]  parent         主窗口对象
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-25
         */
        MaterialEditWidget(Interface::FITKAbaMaterial* material,EventOper::ParaWidgetInterfaceOperator* oper, QWidget* parent);
        /**
         * @brief Destroy the Material Edit Dialog object
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        ~MaterialEditWidget();

        /**
         * @brief 检查数据（失败返回false，成功返回true并存储数据到副本材料对象）
         * @return true 成功
         * @return false 失败
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-06-20
         */
        bool checkValue()override;
        bool saveValue() override;
    private slots :
        ;
        /**
         * @brief ok按钮点击
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        void on_buttonOK_clicked();
        /**
         * @brief 取消按钮点击
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        void on_buttnCancel_clicked();
        /**
         * @brief 编辑材料事件
         * @param[i]  action         按钮
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-22
         */
        void onEditMaterialItem(QAction* action);
        /**
         * @brief 当前item修改
         * @param[i]  current        My Param doc
         * @param[i]  previous       My Param doc
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-22
         */
        void currentItemChanged(QListWidgetItem* current, QListWidgetItem* previous);
        /**
         * @brief item删除事件
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-22
         */
        void onDeleteItemClicked();
        /**
         * @brief 编辑对话框
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-22
         */
        void on_pb_editdesc_clicked();
    private:
        /**
         * @brief 初始化对话框
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        void initDialog();
        /**
         * @brief 更新表格界面
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        void updateListWidget();
        /**
         * @brief 初始化
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-22
         */
        void initMenu();
        /**
         * @brief 根据材料类型显示材料
         * @param[i]  type           材料类型
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        void showItemForm(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType type);
        /**
         * @brief 根据材料类型查找材料
         * @param[i]  type           材料类型
         * @return Interface::FITKAbaMaterialBehavior* 
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        Interface::FITKAbaMaterialBehavior* findMaterialItem(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType type);
        /**
         * @brief 枚举转字符串
         * @param[i]  type           枚举对象
         * @return QString 字符串结果
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-06-20
         */
        QString enumToString(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType type);
        /**
         * @brief General模块初始化
         * @param[i]  menuBar        Action集合
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-06-20
         */
        void initGeneralMenu(QMenuBar* menuBar);
        /**
         * @brief Mechanial中Action初始化
         * @param[i]  menuBar        Action集合
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-06-20
         */
        void initMechanialMenu(QMenuBar* menuBar);
    private:
        /**
         * @brief current widget isCreate
         * @author Liziyang (Liziyang@163.com)
         * @date 2025-01-04
         */
        bool _isCreate = false;
        /**
         * @brief 材料数据对象
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        Interface::FITKAbaMaterial* _material = nullptr;
        /**
         * @brief 材料数据对象副本
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        Interface::FITKAbaMaterial* _tmpMaterial = nullptr;
        /**
         * @brief 材料管理器
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        Interface::FITKMaterialManager* _manager = nullptr;
        /**
         * @brief ui
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        Ui::MaterialEditWidget* _ui = nullptr;
        /**
         * @brief 材料类型
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-07
         */
        Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType _currentItemType =
            Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::None;
        /**
         * @brief 操作器对象
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-25
         */
        //EventOper::ParaWidgetInterfaceOperator* _oper = nullptr;
        /**
         * @brief 存储所有的材料子界面
         * 为满足Abaqus逻辑的要求，将所有widget存储下来，edit边界框结束后在清除widget
         * @author BaGuijun (baguijun@163.com)
         * @date 2024-04-25
         */
        QHash<Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType, MaterialWidgetBase*> _formWidgetHash = {};
    };
}

#endif
